<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link href="favicon.ico" rel="icon" type="image/x-icon" />
		<script type="text/jscript" src="js/jquery-1.8.3.js"></script>
		<script type="text/jscript" src="js/easyui/jquery.easyui.min.js"></script>
		<script type="text/jscript" src="js/easyui/locale/easyui-lang-zh_CN.js"></script>
		<link rel="stylesheet" href="js/easyui/themes/default/easyui.css" />
		<link rel="stylesheet" href="js/easyui/themes/icon.css" />
		<!--引入ztree-->
		<script type="text/javascript" src="js/ztree/jquery.ztree.all-3.5.js" charset="UTF-8"></script>
		<script src="./js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<link rel="stylesheet" type="text/css" href="js/ztree/zTreeStyle.css" />
		<script type="text/javascript">
			//树形菜单
			$(function() {
				//1.进行页面的设置
				var setting = {
					data: {
						simpleData: {
							enable: true //支持简单的数据格式
						}
					},
					callback: {
						onClick: function(event, treeId, treeNode, clickFlag) {

							// 开启一个新的tab页面
							var content = '<div style="width:100%;height:100%;overflow:hidden;">' +
								'<iframe src="' +
								treeNode.page +
								'" scrolling="auto" style="width:100%;height:100%;border:0;" ></iframe></div>';
							//添加选项卡

							//没有内容,不打开选项卡
							if(
								treeNode.page != undefined && treeNode.page != ""
							) {
								//如果选项卡已经打开,选中选项卡
								if($('#mytabs').tabs('exists', treeNode.name)) {
									$('#mytabs').tabs('select', treeNode.name);
								} else {
									//如果没有打开,打开新的选项卡
									$('#mytabs').tabs('add', {
										title: treeNode.name,
										content: content,
										closable: true
									});
								}

							}

						}
					}
				};

				//2.提供ztree 树形菜单的数据
				var zNodes = [
					{ id: 1, pId: 0, name: '父节点一' },
					{ id: 2, pId: 0, name: '父节点二' },
					{ id: 11, pId: 1, name: '子节点一' },
					{ id: 12, pId: 1, name: '子节点二' },
					{ id: 13, pId: 2, name: 'nba', page: "http://china.nba.com" },
					{ id: 14, pId: 2, name: '百度', page: "http://baidu.com" }

				];
				//3.生成树形菜单
				$.fn.zTree.init($('#baseMenu'), setting, zNodes);

				//定义一个被选中的选项卡
				var currentRightTitle;
				//选择选项卡
				$("#mytabs").tabs({
					onContextMenu: function(e, title, index) {
						currentRightTitle = title;
						$("#mm").menu('show', {
							left: e.pageX,
							top: e.pageY
						});
						e.preventDefault();
					}

				});
				$('#mm').menu({
					onClick: function(item) {
						if(item.name === 'Close') {
							$('#mytabs').tabs('close', currentRightTitle);
							//alert(currentRightTitle);
						} else if(item.name === 'CloseOthers') {
							var tabs = $('#mytabs').tabs('tabs');
							$(tabs).each(function() {
								if($(this).panel('options').title != '消息中心' && $(this).panel('options').title != currentRightTitle) {
									$('#mytabs').tabs('close', $(this).panel('options').title);
								}
							});
						} else if(item.name === 'CloseAll') {
							var tabs = $('#mytabs').tabs('tabs');
							$(tabs).each(function() {
								if($(this).panel('options').title != '消息中心') {
									$('#mytabs').tabs('close', $(this).panel('options').title);
								}
							});
						}
					}
				});
			});
		</script>

	</head>

	<body class="easyui-layout">
		<div data-options="region:'north',title:'传智播客管理系统'" style="height: 100px;">北部区域</div>
		<div data-options="region:'west',title:'菜单导航'" style="width: 180px;">

			<div class="easyui-accordion" data-options="fit:true">
				<div data-options="title:'基础菜单'">
					<ul id="baseMenu" class="ztree"></ul>
				</div>
				<div data-options="title:'系统菜单'"></div>

			</div>

		</div>
		<div data-options="region:'center'">
			<!--选项卡面板-->
			<div id="mytabs" class="easyui-tabs" data-options="fit:true">

			</div>

		</div>
		<div data-options="region:'east'" style="width: 100px;">东部区域</div>
		<div data-options="region:'south'" style="height: 80px;">南部区域</div>

		<div id="mm" class="easyui-menu" style="width:120px;">
			<div data-options="name:'Close'">关闭当前窗口</div>
			<div data-options="name:'CloseOthers'">关闭其它窗口</div>
			<div class="menu-sep"></div>
			<!--分割线-->
			<div data-options="iconCls:'icon-cancel',name:'CloseAll'">关闭所有窗口</div>
		</div>

	</body>

</html>